<template>
  <div class="navBar">
    <van-nav-bar
      class="background"
      @click-left="$router.push(path)"
      @click-right="onClickRight"
    >
      <template #left v-if="showLeft">
        <van-icon name="arrow-left" color="#fff" size="18px" />
      </template>
      <template #title>
        <div class="title">{{ title }}</div>
      </template>
      <template #right>
        <div class="right iconfont">{{ right }}</div>
      </template>
    </van-nav-bar>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: undefined
    },
    right: {
      type: String,
      default: undefined
    },
    path: {
      type: String,
      default: undefined
    },
    showLeft: {
      type: Boolean,
      default: true
    }
  },

  methods: {
    onClickLeft () {
      console.log('返回')
    },
    onClickRight () {
      this.$emit('onClickRight')
    }
  }
}
</script>

<style lang="less" scoped>
.navBar {
  .background {
    background-color: @bg;
  }
  .title {
    color: #fff;
    font-size: 18px;
  }
  .right {
    color: #fff;
    font-size: 14px;
  }
}
</style>
